<?php

    class database {
    	protected $db;
    	protected $conn;
    	protected $dbhost;
    	protected $dbuser;
    	protected $dbpswd;
    	protected $dbname;
    	
    	function database($host, $user, $pswd, $db) {
    		$this->dbhost = $host;
    		$this->dbuser = $user;
    		$this->dbpswd = $pswd;
    		$this->dbname = $db;
    	}
    	
    	function connect() {
            // Connect to DB
            $this->con = mysql_connect(
                        $this->dbhost, 
                        $this->dbuser, 
                        $this->dbpswd) 
                or die ($labels["LBL_DB_ERROR"] . mysql_error());
            $this->db = mysql_select_db($this->dbname) or die ($labels["LBL_DB_ERROR"] . mysql_err);
        }
    	
    	function disconnect() {
    		return mysql_close();
    	}
    	
    	function db_error() {
    		return mysql_error();
    	}
    	
    	function do_query($select) {
    		$csr = array();
    		$res = mysql_query($select);
    		
            if ( $res ) {
                while ($row = mysql_fetch_assoc($res)) {
                    $csr[] = $row;
                }
            }
            
            return ($csr);
    	}
    	
    	function do_dml($dml) {
    		mysql_query($dml);
    		return (mysql_affected_rows());
    	}
    }
    
?>